/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.hotel.test.service;

import com.hotel.test.model.BookingClp;
import com.hotel.test.model.HotelClp;
import com.hotel.test.model.LocalClp;
import com.hotel.test.model.RomTypeClp;
import com.hotel.test.model.TblCommentClp;

import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.PropsUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.model.BaseModel;

import java.lang.reflect.Method;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Brian Wing Shun Chan
 */
public class ClpSerializer {
	public static String getServletContextName() {
		if (Validator.isNotNull(_servletContextName)) {
			return _servletContextName;
		}

		synchronized (ClpSerializer.class) {
			if (Validator.isNotNull(_servletContextName)) {
				return _servletContextName;
			}

			try {
				ClassLoader classLoader = ClpSerializer.class.getClassLoader();

				Class<?> portletPropsClass = classLoader.loadClass(
						"com.liferay.util.portlet.PortletProps");

				Method getMethod = portletPropsClass.getMethod("get",
						new Class<?>[] { String.class });

				String portletPropsServletContextName = (String)getMethod.invoke(null,
						"HotelPortal-portlet-deployment-context");

				if (Validator.isNotNull(portletPropsServletContextName)) {
					_servletContextName = portletPropsServletContextName;
				}
			}
			catch (Throwable t) {
				if (_log.isInfoEnabled()) {
					_log.info(
						"Unable to locate deployment context from portlet properties");
				}
			}

			if (Validator.isNull(_servletContextName)) {
				try {
					String propsUtilServletContextName = PropsUtil.get(
							"HotelPortal-portlet-deployment-context");

					if (Validator.isNotNull(propsUtilServletContextName)) {
						_servletContextName = propsUtilServletContextName;
					}
				}
				catch (Throwable t) {
					if (_log.isInfoEnabled()) {
						_log.info(
							"Unable to locate deployment context from portal properties");
					}
				}
			}

			if (Validator.isNull(_servletContextName)) {
				_servletContextName = "HotelPortal-portlet";
			}

			return _servletContextName;
		}
	}

	public static void setClassLoader(ClassLoader classLoader) {
		_classLoader = classLoader;
	}

	public static Object translateInput(BaseModel<?> oldModel) {
		Class<?> oldModelClass = oldModel.getClass();

		String oldModelClassName = oldModelClass.getName();

		if (oldModelClassName.equals(BookingClp.class.getName())) {
			return translateInputBooking(oldModel);
		}

		if (oldModelClassName.equals(HotelClp.class.getName())) {
			return translateInputHotel(oldModel);
		}

		if (oldModelClassName.equals(LocalClp.class.getName())) {
			return translateInputLocal(oldModel);
		}

		if (oldModelClassName.equals(RomTypeClp.class.getName())) {
			return translateInputRomType(oldModel);
		}

		if (oldModelClassName.equals(TblCommentClp.class.getName())) {
			return translateInputTblComment(oldModel);
		}

		return oldModel;
	}

	public static Object translateInput(List<Object> oldList) {
		List<Object> newList = new ArrayList<Object>(oldList.size());

		for (int i = 0; i < oldList.size(); i++) {
			Object curObj = oldList.get(i);

			newList.add(translateInput(curObj));
		}

		return newList;
	}

	public static Object translateInputBooking(BaseModel<?> oldModel) {
		BookingClp oldCplModel = (BookingClp)oldModel;

		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				Class<?> newModelClass = Class.forName("com.hotel.test.model.impl.BookingImpl",
						true, _classLoader);

				Object newModel = newModelClass.newInstance();

				Method method0 = newModelClass.getMethod("setBookId",
						new Class[] { Long.TYPE });

				Long value0 = new Long(oldCplModel.getBookId());

				method0.invoke(newModel, value0);

				Method method1 = newModelClass.getMethod("setUserId",
						new Class[] { Long.TYPE });

				Long value1 = new Long(oldCplModel.getUserId());

				method1.invoke(newModel, value1);

				Method method2 = newModelClass.getMethod("setUserName",
						new Class[] { String.class });

				String value2 = oldCplModel.getUserName();

				method2.invoke(newModel, value2);

				Method method3 = newModelClass.getMethod("setCreateDate",
						new Class[] { Date.class });

				Date value3 = oldCplModel.getCreateDate();

				method3.invoke(newModel, value3);

				Method method4 = newModelClass.getMethod("setModifiedDate",
						new Class[] { Date.class });

				Date value4 = oldCplModel.getModifiedDate();

				method4.invoke(newModel, value4);

				Method method5 = newModelClass.getMethod("setNamePersonBooking",
						new Class[] { String.class });

				String value5 = oldCplModel.getNamePersonBooking();

				method5.invoke(newModel, value5);

				Method method6 = newModelClass.getMethod("setNumberPhone",
						new Class[] { String.class });

				String value6 = oldCplModel.getNumberPhone();

				method6.invoke(newModel, value6);

				Method method7 = newModelClass.getMethod("setEmailBooking",
						new Class[] { String.class });

				String value7 = oldCplModel.getEmailBooking();

				method7.invoke(newModel, value7);

				Method method8 = newModelClass.getMethod("setAddress",
						new Class[] { String.class });

				String value8 = oldCplModel.getAddress();

				method8.invoke(newModel, value8);

				Method method9 = newModelClass.getMethod("setNumberOfGuest",
						new Class[] { Integer.TYPE });

				Integer value9 = new Integer(oldCplModel.getNumberOfGuest());

				method9.invoke(newModel, value9);

				Method method10 = newModelClass.getMethod("setOtherRequest",
						new Class[] { String.class });

				String value10 = oldCplModel.getOtherRequest();

				method10.invoke(newModel, value10);

				Method method11 = newModelClass.getMethod("setDayStart",
						new Class[] { String.class });

				String value11 = oldCplModel.getDayStart();

				method11.invoke(newModel, value11);

				Method method12 = newModelClass.getMethod("setDayFinish",
						new Class[] { String.class });

				String value12 = oldCplModel.getDayFinish();

				method12.invoke(newModel, value12);

				Method method13 = newModelClass.getMethod("setHotelId",
						new Class[] { Long.TYPE });

				Long value13 = new Long(oldCplModel.getHotelId());

				method13.invoke(newModel, value13);

				Method method14 = newModelClass.getMethod("setRomId",
						new Class[] { Long.TYPE });

				Long value14 = new Long(oldCplModel.getRomId());

				method14.invoke(newModel, value14);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateInputHotel(BaseModel<?> oldModel) {
		HotelClp oldCplModel = (HotelClp)oldModel;

		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				Class<?> newModelClass = Class.forName("com.hotel.test.model.impl.HotelImpl",
						true, _classLoader);

				Object newModel = newModelClass.newInstance();

				Method method0 = newModelClass.getMethod("setHotelId",
						new Class[] { Long.TYPE });

				Long value0 = new Long(oldCplModel.getHotelId());

				method0.invoke(newModel, value0);

				Method method1 = newModelClass.getMethod("setUserId",
						new Class[] { Long.TYPE });

				Long value1 = new Long(oldCplModel.getUserId());

				method1.invoke(newModel, value1);

				Method method2 = newModelClass.getMethod("setUserName",
						new Class[] { String.class });

				String value2 = oldCplModel.getUserName();

				method2.invoke(newModel, value2);

				Method method3 = newModelClass.getMethod("setCreateDate",
						new Class[] { Date.class });

				Date value3 = oldCplModel.getCreateDate();

				method3.invoke(newModel, value3);

				Method method4 = newModelClass.getMethod("setModifiedDate",
						new Class[] { Date.class });

				Date value4 = oldCplModel.getModifiedDate();

				method4.invoke(newModel, value4);

				Method method5 = newModelClass.getMethod("setLocalId",
						new Class[] { Long.TYPE });

				Long value5 = new Long(oldCplModel.getLocalId());

				method5.invoke(newModel, value5);

				Method method6 = newModelClass.getMethod("setHotelName",
						new Class[] { String.class });

				String value6 = oldCplModel.getHotelName();

				method6.invoke(newModel, value6);

				Method method7 = newModelClass.getMethod("setQuality",
						new Class[] { String.class });

				String value7 = oldCplModel.getQuality();

				method7.invoke(newModel, value7);

				Method method8 = newModelClass.getMethod("setIntroduce",
						new Class[] { String.class });

				String value8 = oldCplModel.getIntroduce();

				method8.invoke(newModel, value8);

				Method method9 = newModelClass.getMethod("setImage",
						new Class[] { String.class });

				String value9 = oldCplModel.getImage();

				method9.invoke(newModel, value9);

				Method method10 = newModelClass.getMethod("setAddress",
						new Class[] { String.class });

				String value10 = oldCplModel.getAddress();

				method10.invoke(newModel, value10);

				Method method11 = newModelClass.getMethod("setEmail",
						new Class[] { String.class });

				String value11 = oldCplModel.getEmail();

				method11.invoke(newModel, value11);

				Method method12 = newModelClass.getMethod("setPhone",
						new Class[] { String.class });

				String value12 = oldCplModel.getPhone();

				method12.invoke(newModel, value12);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateInputLocal(BaseModel<?> oldModel) {
		LocalClp oldCplModel = (LocalClp)oldModel;

		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				Class<?> newModelClass = Class.forName("com.hotel.test.model.impl.LocalImpl",
						true, _classLoader);

				Object newModel = newModelClass.newInstance();

				Method method0 = newModelClass.getMethod("setLocalId",
						new Class[] { Long.TYPE });

				Long value0 = new Long(oldCplModel.getLocalId());

				method0.invoke(newModel, value0);

				Method method1 = newModelClass.getMethod("setUserId",
						new Class[] { Long.TYPE });

				Long value1 = new Long(oldCplModel.getUserId());

				method1.invoke(newModel, value1);

				Method method2 = newModelClass.getMethod("setUserName",
						new Class[] { String.class });

				String value2 = oldCplModel.getUserName();

				method2.invoke(newModel, value2);

				Method method3 = newModelClass.getMethod("setCreateDate",
						new Class[] { Date.class });

				Date value3 = oldCplModel.getCreateDate();

				method3.invoke(newModel, value3);

				Method method4 = newModelClass.getMethod("setModifiedDate",
						new Class[] { Date.class });

				Date value4 = oldCplModel.getModifiedDate();

				method4.invoke(newModel, value4);

				Method method5 = newModelClass.getMethod("setLocalName",
						new Class[] { String.class });

				String value5 = oldCplModel.getLocalName();

				method5.invoke(newModel, value5);

				Method method6 = newModelClass.getMethod("setIntroduce",
						new Class[] { String.class });

				String value6 = oldCplModel.getIntroduce();

				method6.invoke(newModel, value6);

				Method method7 = newModelClass.getMethod("setImage",
						new Class[] { String.class });

				String value7 = oldCplModel.getImage();

				method7.invoke(newModel, value7);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateInputRomType(BaseModel<?> oldModel) {
		RomTypeClp oldCplModel = (RomTypeClp)oldModel;

		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				Class<?> newModelClass = Class.forName("com.hotel.test.model.impl.RomTypeImpl",
						true, _classLoader);

				Object newModel = newModelClass.newInstance();

				Method method0 = newModelClass.getMethod("setRomId",
						new Class[] { Long.TYPE });

				Long value0 = new Long(oldCplModel.getRomId());

				method0.invoke(newModel, value0);

				Method method1 = newModelClass.getMethod("setUserId",
						new Class[] { Long.TYPE });

				Long value1 = new Long(oldCplModel.getUserId());

				method1.invoke(newModel, value1);

				Method method2 = newModelClass.getMethod("setUserName",
						new Class[] { String.class });

				String value2 = oldCplModel.getUserName();

				method2.invoke(newModel, value2);

				Method method3 = newModelClass.getMethod("setCreateDate",
						new Class[] { Date.class });

				Date value3 = oldCplModel.getCreateDate();

				method3.invoke(newModel, value3);

				Method method4 = newModelClass.getMethod("setModifiedDate",
						new Class[] { Date.class });

				Date value4 = oldCplModel.getModifiedDate();

				method4.invoke(newModel, value4);

				Method method5 = newModelClass.getMethod("setRoomName",
						new Class[] { String.class });

				String value5 = oldCplModel.getRoomName();

				method5.invoke(newModel, value5);

				Method method6 = newModelClass.getMethod("setInformation",
						new Class[] { String.class });

				String value6 = oldCplModel.getInformation();

				method6.invoke(newModel, value6);

				Method method7 = newModelClass.getMethod("setNumberOfGuest",
						new Class[] { Integer.TYPE });

				Integer value7 = new Integer(oldCplModel.getNumberOfGuest());

				method7.invoke(newModel, value7);

				Method method8 = newModelClass.getMethod("setRice",
						new Class[] { String.class });

				String value8 = oldCplModel.getRice();

				method8.invoke(newModel, value8);

				Method method9 = newModelClass.getMethod("setNumberOfRoom",
						new Class[] { Integer.TYPE });

				Integer value9 = new Integer(oldCplModel.getNumberOfRoom());

				method9.invoke(newModel, value9);

				Method method10 = newModelClass.getMethod("setHotelId",
						new Class[] { Long.TYPE });

				Long value10 = new Long(oldCplModel.getHotelId());

				method10.invoke(newModel, value10);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateInputTblComment(BaseModel<?> oldModel) {
		TblCommentClp oldCplModel = (TblCommentClp)oldModel;

		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				Class<?> newModelClass = Class.forName("com.hotel.test.model.impl.TblCommentImpl",
						true, _classLoader);

				Object newModel = newModelClass.newInstance();

				Method method0 = newModelClass.getMethod("setCommentId",
						new Class[] { Long.TYPE });

				Long value0 = new Long(oldCplModel.getCommentId());

				method0.invoke(newModel, value0);

				Method method1 = newModelClass.getMethod("setUserId",
						new Class[] { Long.TYPE });

				Long value1 = new Long(oldCplModel.getUserId());

				method1.invoke(newModel, value1);

				Method method2 = newModelClass.getMethod("setUserName",
						new Class[] { String.class });

				String value2 = oldCplModel.getUserName();

				method2.invoke(newModel, value2);

				Method method3 = newModelClass.getMethod("setCreateDate",
						new Class[] { Date.class });

				Date value3 = oldCplModel.getCreateDate();

				method3.invoke(newModel, value3);

				Method method4 = newModelClass.getMethod("setModifiedDate",
						new Class[] { Date.class });

				Date value4 = oldCplModel.getModifiedDate();

				method4.invoke(newModel, value4);

				Method method5 = newModelClass.getMethod("setComment",
						new Class[] { String.class });

				String value5 = oldCplModel.getComment();

				method5.invoke(newModel, value5);

				Method method6 = newModelClass.getMethod("setHotelId",
						new Class[] { Long.TYPE });

				Long value6 = new Long(oldCplModel.getHotelId());

				method6.invoke(newModel, value6);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateInput(Object obj) {
		if (obj instanceof BaseModel<?>) {
			return translateInput((BaseModel<?>)obj);
		}
		else if (obj instanceof List<?>) {
			return translateInput((List<Object>)obj);
		}
		else {
			return obj;
		}
	}

	public static Object translateOutput(BaseModel<?> oldModel) {
		Class<?> oldModelClass = oldModel.getClass();

		String oldModelClassName = oldModelClass.getName();

		if (oldModelClassName.equals("com.hotel.test.model.impl.BookingImpl")) {
			return translateOutputBooking(oldModel);
		}

		if (oldModelClassName.equals("com.hotel.test.model.impl.HotelImpl")) {
			return translateOutputHotel(oldModel);
		}

		if (oldModelClassName.equals("com.hotel.test.model.impl.LocalImpl")) {
			return translateOutputLocal(oldModel);
		}

		if (oldModelClassName.equals("com.hotel.test.model.impl.RomTypeImpl")) {
			return translateOutputRomType(oldModel);
		}

		if (oldModelClassName.equals("com.hotel.test.model.impl.TblCommentImpl")) {
			return translateOutputTblComment(oldModel);
		}

		return oldModel;
	}

	public static Object translateOutput(List<Object> oldList) {
		List<Object> newList = new ArrayList<Object>(oldList.size());

		for (int i = 0; i < oldList.size(); i++) {
			Object curObj = oldList.get(i);

			newList.add(translateOutput(curObj));
		}

		return newList;
	}

	public static Object translateOutput(Object obj) {
		if (obj instanceof BaseModel<?>) {
			return translateOutput((BaseModel<?>)obj);
		}
		else if (obj instanceof List<?>) {
			return translateOutput((List<Object>)obj);
		}
		else {
			return obj;
		}
	}

	public static Object translateOutputBooking(BaseModel<?> oldModel) {
		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				BookingClp newModel = new BookingClp();

				Class<?> oldModelClass = oldModel.getClass();

				Method method0 = oldModelClass.getMethod("getBookId");

				Long value0 = (Long)method0.invoke(oldModel, (Object[])null);

				newModel.setBookId(value0);

				Method method1 = oldModelClass.getMethod("getUserId");

				Long value1 = (Long)method1.invoke(oldModel, (Object[])null);

				newModel.setUserId(value1);

				Method method2 = oldModelClass.getMethod("getUserName");

				String value2 = (String)method2.invoke(oldModel, (Object[])null);

				newModel.setUserName(value2);

				Method method3 = oldModelClass.getMethod("getCreateDate");

				Date value3 = (Date)method3.invoke(oldModel, (Object[])null);

				newModel.setCreateDate(value3);

				Method method4 = oldModelClass.getMethod("getModifiedDate");

				Date value4 = (Date)method4.invoke(oldModel, (Object[])null);

				newModel.setModifiedDate(value4);

				Method method5 = oldModelClass.getMethod("getNamePersonBooking");

				String value5 = (String)method5.invoke(oldModel, (Object[])null);

				newModel.setNamePersonBooking(value5);

				Method method6 = oldModelClass.getMethod("getNumberPhone");

				String value6 = (String)method6.invoke(oldModel, (Object[])null);

				newModel.setNumberPhone(value6);

				Method method7 = oldModelClass.getMethod("getEmailBooking");

				String value7 = (String)method7.invoke(oldModel, (Object[])null);

				newModel.setEmailBooking(value7);

				Method method8 = oldModelClass.getMethod("getAddress");

				String value8 = (String)method8.invoke(oldModel, (Object[])null);

				newModel.setAddress(value8);

				Method method9 = oldModelClass.getMethod("getNumberOfGuest");

				Integer value9 = (Integer)method9.invoke(oldModel,
						(Object[])null);

				newModel.setNumberOfGuest(value9);

				Method method10 = oldModelClass.getMethod("getOtherRequest");

				String value10 = (String)method10.invoke(oldModel,
						(Object[])null);

				newModel.setOtherRequest(value10);

				Method method11 = oldModelClass.getMethod("getDayStart");

				String value11 = (String)method11.invoke(oldModel,
						(Object[])null);

				newModel.setDayStart(value11);

				Method method12 = oldModelClass.getMethod("getDayFinish");

				String value12 = (String)method12.invoke(oldModel,
						(Object[])null);

				newModel.setDayFinish(value12);

				Method method13 = oldModelClass.getMethod("getHotelId");

				Long value13 = (Long)method13.invoke(oldModel, (Object[])null);

				newModel.setHotelId(value13);

				Method method14 = oldModelClass.getMethod("getRomId");

				Long value14 = (Long)method14.invoke(oldModel, (Object[])null);

				newModel.setRomId(value14);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateOutputHotel(BaseModel<?> oldModel) {
		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				HotelClp newModel = new HotelClp();

				Class<?> oldModelClass = oldModel.getClass();

				Method method0 = oldModelClass.getMethod("getHotelId");

				Long value0 = (Long)method0.invoke(oldModel, (Object[])null);

				newModel.setHotelId(value0);

				Method method1 = oldModelClass.getMethod("getUserId");

				Long value1 = (Long)method1.invoke(oldModel, (Object[])null);

				newModel.setUserId(value1);

				Method method2 = oldModelClass.getMethod("getUserName");

				String value2 = (String)method2.invoke(oldModel, (Object[])null);

				newModel.setUserName(value2);

				Method method3 = oldModelClass.getMethod("getCreateDate");

				Date value3 = (Date)method3.invoke(oldModel, (Object[])null);

				newModel.setCreateDate(value3);

				Method method4 = oldModelClass.getMethod("getModifiedDate");

				Date value4 = (Date)method4.invoke(oldModel, (Object[])null);

				newModel.setModifiedDate(value4);

				Method method5 = oldModelClass.getMethod("getLocalId");

				Long value5 = (Long)method5.invoke(oldModel, (Object[])null);

				newModel.setLocalId(value5);

				Method method6 = oldModelClass.getMethod("getHotelName");

				String value6 = (String)method6.invoke(oldModel, (Object[])null);

				newModel.setHotelName(value6);

				Method method7 = oldModelClass.getMethod("getQuality");

				String value7 = (String)method7.invoke(oldModel, (Object[])null);

				newModel.setQuality(value7);

				Method method8 = oldModelClass.getMethod("getIntroduce");

				String value8 = (String)method8.invoke(oldModel, (Object[])null);

				newModel.setIntroduce(value8);

				Method method9 = oldModelClass.getMethod("getImage");

				String value9 = (String)method9.invoke(oldModel, (Object[])null);

				newModel.setImage(value9);

				Method method10 = oldModelClass.getMethod("getAddress");

				String value10 = (String)method10.invoke(oldModel,
						(Object[])null);

				newModel.setAddress(value10);

				Method method11 = oldModelClass.getMethod("getEmail");

				String value11 = (String)method11.invoke(oldModel,
						(Object[])null);

				newModel.setEmail(value11);

				Method method12 = oldModelClass.getMethod("getPhone");

				String value12 = (String)method12.invoke(oldModel,
						(Object[])null);

				newModel.setPhone(value12);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateOutputLocal(BaseModel<?> oldModel) {
		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				LocalClp newModel = new LocalClp();

				Class<?> oldModelClass = oldModel.getClass();

				Method method0 = oldModelClass.getMethod("getLocalId");

				Long value0 = (Long)method0.invoke(oldModel, (Object[])null);

				newModel.setLocalId(value0);

				Method method1 = oldModelClass.getMethod("getUserId");

				Long value1 = (Long)method1.invoke(oldModel, (Object[])null);

				newModel.setUserId(value1);

				Method method2 = oldModelClass.getMethod("getUserName");

				String value2 = (String)method2.invoke(oldModel, (Object[])null);

				newModel.setUserName(value2);

				Method method3 = oldModelClass.getMethod("getCreateDate");

				Date value3 = (Date)method3.invoke(oldModel, (Object[])null);

				newModel.setCreateDate(value3);

				Method method4 = oldModelClass.getMethod("getModifiedDate");

				Date value4 = (Date)method4.invoke(oldModel, (Object[])null);

				newModel.setModifiedDate(value4);

				Method method5 = oldModelClass.getMethod("getLocalName");

				String value5 = (String)method5.invoke(oldModel, (Object[])null);

				newModel.setLocalName(value5);

				Method method6 = oldModelClass.getMethod("getIntroduce");

				String value6 = (String)method6.invoke(oldModel, (Object[])null);

				newModel.setIntroduce(value6);

				Method method7 = oldModelClass.getMethod("getImage");

				String value7 = (String)method7.invoke(oldModel, (Object[])null);

				newModel.setImage(value7);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateOutputRomType(BaseModel<?> oldModel) {
		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				RomTypeClp newModel = new RomTypeClp();

				Class<?> oldModelClass = oldModel.getClass();

				Method method0 = oldModelClass.getMethod("getRomId");

				Long value0 = (Long)method0.invoke(oldModel, (Object[])null);

				newModel.setRomId(value0);

				Method method1 = oldModelClass.getMethod("getUserId");

				Long value1 = (Long)method1.invoke(oldModel, (Object[])null);

				newModel.setUserId(value1);

				Method method2 = oldModelClass.getMethod("getUserName");

				String value2 = (String)method2.invoke(oldModel, (Object[])null);

				newModel.setUserName(value2);

				Method method3 = oldModelClass.getMethod("getCreateDate");

				Date value3 = (Date)method3.invoke(oldModel, (Object[])null);

				newModel.setCreateDate(value3);

				Method method4 = oldModelClass.getMethod("getModifiedDate");

				Date value4 = (Date)method4.invoke(oldModel, (Object[])null);

				newModel.setModifiedDate(value4);

				Method method5 = oldModelClass.getMethod("getRoomName");

				String value5 = (String)method5.invoke(oldModel, (Object[])null);

				newModel.setRoomName(value5);

				Method method6 = oldModelClass.getMethod("getInformation");

				String value6 = (String)method6.invoke(oldModel, (Object[])null);

				newModel.setInformation(value6);

				Method method7 = oldModelClass.getMethod("getNumberOfGuest");

				Integer value7 = (Integer)method7.invoke(oldModel,
						(Object[])null);

				newModel.setNumberOfGuest(value7);

				Method method8 = oldModelClass.getMethod("getRice");

				String value8 = (String)method8.invoke(oldModel, (Object[])null);

				newModel.setRice(value8);

				Method method9 = oldModelClass.getMethod("getNumberOfRoom");

				Integer value9 = (Integer)method9.invoke(oldModel,
						(Object[])null);

				newModel.setNumberOfRoom(value9);

				Method method10 = oldModelClass.getMethod("getHotelId");

				Long value10 = (Long)method10.invoke(oldModel, (Object[])null);

				newModel.setHotelId(value10);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	public static Object translateOutputTblComment(BaseModel<?> oldModel) {
		Thread currentThread = Thread.currentThread();

		ClassLoader contextClassLoader = currentThread.getContextClassLoader();

		try {
			currentThread.setContextClassLoader(_classLoader);

			try {
				TblCommentClp newModel = new TblCommentClp();

				Class<?> oldModelClass = oldModel.getClass();

				Method method0 = oldModelClass.getMethod("getCommentId");

				Long value0 = (Long)method0.invoke(oldModel, (Object[])null);

				newModel.setCommentId(value0);

				Method method1 = oldModelClass.getMethod("getUserId");

				Long value1 = (Long)method1.invoke(oldModel, (Object[])null);

				newModel.setUserId(value1);

				Method method2 = oldModelClass.getMethod("getUserName");

				String value2 = (String)method2.invoke(oldModel, (Object[])null);

				newModel.setUserName(value2);

				Method method3 = oldModelClass.getMethod("getCreateDate");

				Date value3 = (Date)method3.invoke(oldModel, (Object[])null);

				newModel.setCreateDate(value3);

				Method method4 = oldModelClass.getMethod("getModifiedDate");

				Date value4 = (Date)method4.invoke(oldModel, (Object[])null);

				newModel.setModifiedDate(value4);

				Method method5 = oldModelClass.getMethod("getComment");

				String value5 = (String)method5.invoke(oldModel, (Object[])null);

				newModel.setComment(value5);

				Method method6 = oldModelClass.getMethod("getHotelId");

				Long value6 = (Long)method6.invoke(oldModel, (Object[])null);

				newModel.setHotelId(value6);

				return newModel;
			}
			catch (Exception e) {
				_log.error(e, e);
			}
		}
		finally {
			currentThread.setContextClassLoader(contextClassLoader);
		}

		return oldModel;
	}

	private static Log _log = LogFactoryUtil.getLog(ClpSerializer.class);
	private static ClassLoader _classLoader;
	private static String _servletContextName;
}